package com.example.a79273.shandianban.model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2016/8/30.
 */
public class YouHuoProductTopImgsBean {

    /**
     * error_code : 0
     * error_msg : 获取分类产品成功
     * data : {"list":[{"pic_id":"","pic_scr_b":"/Upload/Product/240000760327/37e1383bed.jpg","pic_scr_s":"/Upload/Product/240000760327/37e1383bed.jpg","pic_url":"","pic_text":""},{"pic_id":"","pic_scr_b":"/Upload/Product/240000760327/37e1383bda.jpg","pic_scr_s":"/Upload/Product/240000760327/37e1383bda.jpg","pic_url":"","pic_text":""},{"pic_id":"","pic_scr_b":"/Upload/Product/240000760327/37e1383be5.jpg","pic_scr_s":"/Upload/Product/240000760327/37e1383be5.jpg","pic_url":"","pic_text":""},{"pic_id":"","pic_scr_b":"/Upload/Product/240000760327/37e1383c5e.jpg","pic_scr_s":"/Upload/Product/240000760327/37e1383c5e.jpg","pic_url":"","pic_text":""},{"pic_id":"","pic_scr_b":"/Upload/Product/240000760327/37e1383c73.jpg","pic_scr_s":"/Upload/Product/240000760327/37e1383c73.jpg","pic_url":"","pic_text":""}]}
     */

    private int error_code;
    private String error_msg;
    private DataBean data;

    public static YouHuoProductTopImgsBean objectFromData(String str) {

        return new Gson().fromJson(str, YouHuoProductTopImgsBean.class);
    }

    public static YouHuoProductTopImgsBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), YouHuoProductTopImgsBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<YouHuoProductTopImgsBean> arrayYouHuoProductTopImgsBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<YouHuoProductTopImgsBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<YouHuoProductTopImgsBean> arrayYouHuoProductTopImgsBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<YouHuoProductTopImgsBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getError_code() {
        return error_code;
    }

    public void setError_code(int error_code) {
        this.error_code = error_code;
    }

    public String getError_msg() {
        return error_msg;
    }

    public void setError_msg(String error_msg) {
        this.error_msg = error_msg;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * pic_id :
         * pic_scr_b : /Upload/Product/240000760327/37e1383bed.jpg
         * pic_scr_s : /Upload/Product/240000760327/37e1383bed.jpg
         * pic_url :
         * pic_text :
         */

        private List<ListBean> list;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class ListBean {
            private String pic_id;
            private String pic_scr_b;
            private String pic_scr_s;
            private String pic_url;
            private String pic_text;

            public static ListBean objectFromData(String str) {

                return new Gson().fromJson(str, ListBean.class);
            }

            public static ListBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ListBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ListBean> arrayListBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ListBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ListBean> arrayListBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ListBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public String getPic_id() {
                return pic_id;
            }

            public void setPic_id(String pic_id) {
                this.pic_id = pic_id;
            }

            public String getPic_scr_b() {
                return pic_scr_b;
            }

            public void setPic_scr_b(String pic_scr_b) {
                this.pic_scr_b = pic_scr_b;
            }

            public String getPic_scr_s() {
                return pic_scr_s;
            }

            public void setPic_scr_s(String pic_scr_s) {
                this.pic_scr_s = pic_scr_s;
            }

            public String getPic_url() {
                return pic_url;
            }

            public void setPic_url(String pic_url) {
                this.pic_url = pic_url;
            }

            public String getPic_text() {
                return pic_text;
            }

            public void setPic_text(String pic_text) {
                this.pic_text = pic_text;
            }
        }
    }
}
